<?php
/**
 * (exporter)
 */
namespace App\Exporter\Warehousing;

use Maatwebsite\Excel\Concerns\FromView;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnWidths;
use Maatwebsite\Excel\Concerns\WithProperties;
use Maatwebsite\Excel\Concerns\WithStyles;
use Maatwebsite\Excel\Concerns\WithTitle;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class ReceiveExporter implements FromView,WithProperties,WithTitle,ShouldAutoSize,WithColumnWidths,WithStyles
{
    protected $purchase;

    public function __construct($purchase)
    {
        $this->purchase = $purchase;
    }

    public function styles(Worksheet $sheet)
    {
        $sheet->getStyle('A:F')->getAlignment()
            ->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
    }

    public function columnWidths(): array
    {
        return ['A' => 20, 'B' => 60,'C' => 20, 'D' => 20, 'E' => 20];
    }

    public function properties(): array
    {
        return [
            'creator'        => '新钱潮科技',
            'title'          => '采购单',
            'description'    => '采购单',
            'company'        => '新钱潮科技',
        ];
    }

    public function title(): string
    {
        return '采购单';
    }

    public function view(): View
    {
        $purchase = $this->purchase;
        return view('warehousing.receive-export.index', compact('purchase'));
    }

}
